import request from '@/utils/request';
import type { AxiosPromise } from 'axios';
import type { GoodsCategoryVO,  GoodsCategoryQuery } from '@/api/home/goodsCategory/types.ts';
import type { RouteParamValue } from 'vue-router'

/**
 * 查询商品分类列表
 * @param query
 * @returns {*}
 */

export const listCategoryApi = (query?: GoodsCategoryQuery): AxiosPromise<GoodsCategoryVO[]> => {
  return request({
    url: '/api/goods/category/list',
    method: 'get',
    params: query
  });
};
/**
 * 查询商品分类列表
 * @returns {*}
 * @param id
 */

export const towListApi = (id: string | RouteParamValue[]): AxiosPromise<GoodsCategoryVO[]> => {
  return request({
    url: `/api/goods/category/list/${id}`,
    method: 'get',
  });
};
/**
 * 查询商品分类详细
 * @param id
 */
export const getCategoryApi = (id?:string | string[] | number): AxiosPromise<GoodsCategoryVO> => {
  return request({
    url: '/api/goods/category/' + id,
    method: 'get'
  });
};
/**
 * 查询二级商品分类详细
 * @param id
 */
export const getCategoryTwoApi = (id?:string | string[]): AxiosPromise<GoodsCategoryVO> => {
  return request({
    url: '/api/goods/category/sub/' + id,
    method: 'get'
  });
};

